/**
 * Created by dongp on 2018/1/20.
 */
$(function (){

    addUser();
    cancelUser();

});

function addUser(){

    $("#addRole_save").on("click",function (){

        if(Kit.isEmpty($("#roleName").val())) {
            $.messager.alert("帮助提示","请输入角色名");
            return false;
        }
        if(Kit.isEmpty($("#roleValue").val())) {
            $.messager.alert("帮助提示","请输入角色值");
            return false;
        }
        var sendData = {
            roleName: $("#roleName").val(),
            roleValue: $("#roleValue").val(),
        }

        ui.request({
            url:"/admin/role/add",
            data:sendData,
            success:function (rtn) {
                console.log(rtn)
                if(rtn.code != undefined && rtn.code !== "0000"){
                    $.messager.alert(rtn.msg,rtn.desc);
                }
                $('#win').window('close');
                $("#roleList").datagrid("reload",{});
            }
        })
    });
}

function cancelUser() {
    $("#addRole_cancel").on("click",function (){
        $('#win').window('close');
    });
}